package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperatePlanManageInfoDTO;
import com.itlong.cloud.POJO.DTO.operate.OperatePlanManagePageDTO;
import com.itlong.cloud.POJO.VO.operate.OperatePlanManageInfoVO;
import com.itlong.cloud.equip.operate.IOperatePlanManageServiceClient;
import com.itlong.cloud.operate.service.IOperatePlanManageService;
import com.itlong.cloud.utils.page.Page;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <desc>
 *     运营-智慧停车-设备方案管理露接口实现类。
 * <desc/>
 *
 * @createDate 2018/11/05.
 */
@RestController
public class OperatePlanManageServiceResource implements IOperatePlanManageServiceClient {

    private static final Logger LOG = LoggerFactory.getLogger(OperatePlanManageServiceResource.class);

    @Autowired
    IOperatePlanManageService iOperatePlanManageService;

    /**
     * <desc>
     *      分页获取设备方案信息。
     * <desc/>
     *
     * @param  operatePlanManagePageDTO 参数请求对象
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/getPlanInfoPage",method = RequestMethod.POST)
    public Page<OperatePlanManageInfoVO> getPlanInfoPage(@RequestBody OperatePlanManagePageDTO operatePlanManagePageDTO) throws Exception{
        return iOperatePlanManageService.getPlanInfoPage(operatePlanManagePageDTO);
     }

    /**
     * <desc>
     *      判断方案名称是否重复。
     * <desc/>
     *
     * @param  planName 方案名称
     * @param  planId 方案编号
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/checkPlanName",method = RequestMethod.POST)
    public Integer checkPlanName(@RequestParam("planName")String planName, @RequestParam(value = "planId",required=false)String planId) throws Exception{
        return iOperatePlanManageService.checkPlanName(planName,planId);
    }

    /**
     * <desc>
     *      保存设备方案。
     * <desc/>
     *
     * @param  operatePlanManageInfoDTO 参数请求对象
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/save",method = RequestMethod.POST)
    public Integer save(@RequestBody OperatePlanManageInfoDTO operatePlanManageInfoDTO) throws Exception{
        return iOperatePlanManageService.save(operatePlanManageInfoDTO);
    }

    /**
     * <desc>
     *      更新设备方案。
     * <desc/>
     *
     * @param  operatePlanManageInfoDTO 参数请求对象
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/update",method = RequestMethod.POST)
    public Integer update(@RequestBody OperatePlanManageInfoDTO operatePlanManageInfoDTO) throws Exception{
        return iOperatePlanManageService.update(operatePlanManageInfoDTO);
    }

    /**
     * <desc>
     *      删除设备方案。
     * <desc/>
     *
     * @param  operatePlanManageInfoDTO 参数请求对象
     * @return
     * @author Qiang.S
     * @createDate 2018/11/05
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/delete",method = RequestMethod.POST)
    public Integer delete(@RequestBody OperatePlanManageInfoDTO operatePlanManageInfoDTO) throws Exception{
        return iOperatePlanManageService.delete(operatePlanManageInfoDTO);
    }

    /**
     * <desc>
     *      根据方案编号获取名称
     * <desc/>
     *
     * @param planId 方案编号
     * @return
     * @author Qiang.S
     * @createDate 2018-09-25
     */
    @Override
    @RequestMapping(path = "/operate/parking/planManage/getDetail",method = RequestMethod.POST)
    public OperatePlanManageInfoVO getDetail(@RequestParam("planId") String planId) throws Exception{
        return iOperatePlanManageService.getDetail(planId);
    }

}
